package com.apes.scm.masterdata.product.service;

import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import com.apes.scm.masterdata.product.model.ProductSoldOut;
import com.apes.scm.masterdata.product.repository.ProductSoldOutRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName ProductSoldOutService
 * @Description TODO
 * @Author pengyb
 * @Date 2019/12/25 14:09
 * @Version 1.0
 **/
@Service("productSoldOutService")
public class ProductSoldOutService extends DomainService {
    ProductSoldOutRepository productSoldOutRepository;

    @Autowired
    private void setProductSoldOutRepository(ProductSoldOutRepository productSoldOutRepository) {
        this.productSoldOutRepository = productSoldOutRepository;
    }

    public ProductSoldOut save(SimpleRequest request) {
        ProductSoldOut sold = request.getO(ProductSoldOut.class);
        return productSoldOutRepository.saveAndFlush(sold);
    }

    public String delete(SimpleRequest request) {
        ProductSoldOut sold = request.getO(ProductSoldOut.class);
        productSoldOutRepository.delete(sold.getId());
        return "删除成功";
    }

}
